/**
 * 溶解氧电极液
 */
Bottle = Widget.extend({
	ctor:function(){
		this._super();
		this.init();
		this.setTag(TAG_BOTTLE_ALL);
	},
	init:function(){
		this.body = new Button(this, 10, TAG_BOTTLE, "#bottle.png", this.callback,this);
		var lid=new Button(this,10,TAG_LID,"#lid1.png",this.callback,this);
		lid.setPosition(cc.p(this.body.width*0.02,this.body.height*0.48));
		
		var lid1=new Button(this,10,TAG_LID_1,"#lid2.png",this.callback,this);
		lid1.setVisible(false);
		
		//拿校正液瓶右手
		var right_1=new Button(this,10,TAG_RIGHT_1,"#right_1.png",this.callback,this);
		right_1.setPosition(this.width*0.5+50,this.height*0.5);
		right_1.setVisible(false);
		var right_2=new Button(right_1,10,TAG_RIGHT_2,"#right_2.png",this.callback,this);
		right_2.setPosition(right_1.width*0.5,right_1.height*0.5);
		var right_3=new Button(right_1,10,TAG_RIGHT_3,"#right_3.png",this.callback,this);
		right_3.setPosition(right_1.width*0.5,right_1.height*0.5);
	},
	show:function(){
		var electrode_show=new Button(this,15,TAG_ELECTRODE_SHOW1,"#electrode_show.png",this.callback,this);
		electrode_show.setPosition(cc.p(-this.body.width-315,this.body.height+35));
		electrode_show.setOpacity(0);
		var fadein=cc.fadeIn(1);
		var fadeout=cc.fadeOut(1);
		electrode_show.runAction(cc.sequence(fadein,cc.delayTime(1),fadeout));
	},
	callback:function(p){
		var func=cc.callFunc(function(){
			gg.flow.next();
		},this);
		var body=this.getChildByTag(TAG_BOTTLE);
		var right_1=this.getChildByTag(TAG_RIGHT_1);
		var right_2=this.getChildByTag(TAG_RIGHT_2);
		var right_3=this.getChildByTag(TAG_RIGHT_3);
		var lid1=this.getChildByTag(TAG_LID_1);
		var lid=this.getChildByTag(TAG_LID);
		switch(p.getTag()){
		case TAG_BOTTLE:
			var ber=cc.bezierBy(1, [cc.p(-10,30),cc.p(-50, 80),cc.p(-310, 150)]);
			var rotate=cc.rotateBy(1,-80);
			body.setVisible(false);
			right_1.setVisible(true);
			right_1.runAction(cc.sequence(ber,rotate,cc.delayTime(1),rotate.reverse(),cc.callFunc(function() {
				lid1.setVisible(false);
				this.show();
			},this),cc.callFunc(function() {
				right_1.setVisible(false);
			},this),cc.delayTime(3),func));
			break;
		case TAG_LID:
			var ber=cc.bezierBy(1.5, [cc.p(50,70),cc.p(65,-80),cc.p(65,-90)]);
			var rotate=cc.rotateBy(1.5,180);
			var lid=this.getChildByTag(TAG_LID);
			lid.runAction(cc.sequence(cc.spawn(ber,rotate),cc.callFunc(function() {
				lid.setVisible(false);
				lid1.setVisible(true);
				lid1.setPosition(cc.p(lid.getPositionX(),lid.getPositionY()));
			},this),func));
			break;
		default:
			break;
		}
	}
});